package cj.web.admin.dao;
/*
 *  
 *  
*/
import java.util.List;
import net.paoding.rose.jade.annotation.DAO;
import net.paoding.rose.jade.annotation.SQL;
import net.paoding.rose.jade.annotation.SQLParam;
import cj.web.admin.domain.Lexicon;

/**
 * 
 * @author 
 *
 */
@DAO
public interface LexiconDAO{
	
	@SQL("SELECT * FROM Lexicon WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ORDER BY updateAt DESC LIMIT :t.start,:t.length ")
    List<Lexicon> query(@SQLParam("t") Lexicon lexicon);
	
	@SQL("SELECT count(*) FROM Lexicon WHERE deleteFlag=1 #if(:t.name!=''){AND name like '%##(:t.name)%' } ")
    int querySize(@SQLParam("t") Lexicon lexicon);
    
    @SQL("select * from Lexicon where id=:1")
    Lexicon queryById(int id);
    
    @SQL("INSERT INTO Lexicon (name,deleteFlag,createUser,createAt,updateUser,updateAt) VALUES (:t.name,:t.deleteFlag,:t.createUser,now(),:t.updateUser,now())")
    void create(@SQLParam("t") Lexicon lexicon);
	
	@SQL("UPDATE Lexicon SET name=:t.name,updateUser=:t.updateUser,updateAt=now() WHERE id=:t.id")
    void update(@SQLParam("t") Lexicon lexicon);
    
    @SQL("UPDATE Lexicon SET deleteFlag=0 WHERE id=:1")
    void deleteById(int id);
}